/*
 * Created by SharpDevelop.
 * user: Robertux
 * Date: 29/04/2008
 * Time: 12:44
 * 
 * 
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using DataLayer;
using Inventador;

namespace WinApp
{
	/// <summary>
	/// Description of frmAddPrecio.
	/// </summary>
	public partial class frmAddPrecio : Form
	{
		private BaseDatos bdatos;
		private Producto prod;
		
		public frmAddPrecio()
		{
			InitializeComponent();
		}
		
		public frmAddPrecio(BaseDatos bdatosExterna, Producto prd): this()
		{
			this.bdatos = bdatosExterna;
			this.prod = prd;
		}
		
		void Button1Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}
		
		void Button2Click(object sender, EventArgs e)
		{
			int newId = Precio.GetMaxId(this.bdatos) + 1;
			Precio pr = new Precio(newId, this.dateTimePicker1.Value, Double.Parse(this.numericUpDown1.Value.ToString()), this.prod);
			pr.Insert(this.bdatos);
			this.DialogResult = DialogResult.OK;
			this.Close();
		}
	}
}
